import { BasicColumn, FormSchema } from '@/components/Table';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';
import {importTemplateApi} from "@/views/sys/cc/template/api/template.api";

// 表格
export const columns: BasicColumn[] = [
  {
    title: 'ID',
    dataIndex: 'id',
    width: 200,
    align: 'left',
  },
  {
    title: '名称',
    dataIndex: 'name',
    width: 200,
    align: 'left',
  },
  {
    title: '测试字段',
    dataIndex: 'test',
  },
  {
    title: '测试字段',
    dataIndex: 'aaaa',
  },
  {
    title: '状态',
    dataIndex: 'status',
    width: 80,
    customRender: ({ record }) => {
      const status = record.status;
      const enable = ~~status === 0;
      const color = enable ? 'green' : 'red';
      const text = enable ? '启用' : '停用';
      return h(Tag, { color: color }, () => text);
    },
  },
  {
    title: '创建时间',
    dataIndex: 'created_at',
    width: 180,
  },
  {
    title: '最近一次编辑时间',
    dataIndex: 'updated_at',
    width: 180,
  },
];
// 表格结束

// 搜索
export const searchFormSchema: FormSchema[] = [
  {
    field: 'name',
    label: '菜单名称',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    field: 'status',
    label: '状态',
    component: 'Select',
    componentProps: {
      options: [
        { label: '启用', value: '0' },
        { label: '停用', value: '1' },
      ],
    },
    colProps: { span: 8 },
  },
];
// 搜索结束

// 表单
export const formSchema: FormSchema[] = [
  {
    field: 'name',
    label: '测试名称',
    component: 'Input',
    required: true,
  },
  {
    field: 'test',
    label: '测试名称test',
    component: 'Input',
    required: true,
  },
  {
    field: 'aaaa',
    label: '测试名称aaaa',
    component: 'Input',
    required: true,
  },
  {
    label: '备注',
    field: 'illustrate',
    component: 'InputTextArea',
  },
];
// 表单结束

// Excel
export const excelFormSchema: FormSchema[] = [
  {
    field: 'excel',
    label: 'excel文件',
    component: 'Upload',
    componentProps: {
      api: importTemplateApi
    },
    required: true,
  },
];
// Excel结束
